package com.rbac.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.rbac.common.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 权限实体类
 *
 * @author rbac-system
 * @since 2024-01-01
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_permission")
@ApiModel(value = "SysPermission对象", description = "权限表")
public class SysPermission extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "权限名称")
    @NotBlank(message = "权限名称不能为空")
    @TableField("permission_name")
    private String permissionName;

    @ApiModelProperty(value = "权限编码")
    @NotBlank(message = "权限编码不能为空")
    @TableField("permission_code")
    private String permissionCode;

    @ApiModelProperty(value = "资源类型：1-菜单，2-按钮，3-接口")
    @NotNull(message = "资源类型不能为空")
    @TableField("resource_type")
    private Integer resourceType;

    @ApiModelProperty(value = "资源路径")
    @TableField("resource_path")
    private String resourcePath;

    @ApiModelProperty(value = "请求方法：GET,POST,PUT,DELETE等")
    @TableField("method")
    private String method;

    @ApiModelProperty(value = "父权限ID")
    @TableField("parent_id")
    private Long parentId;

    @ApiModelProperty(value = "权限描述")
    @TableField("description")
    private String description;

    @ApiModelProperty(value = "状态：0-禁用，1-启用")
    @TableField("status")
    private Integer status;

    @ApiModelProperty(value = "排序")
    @TableField("sort_order")
    private Integer sortOrder;

    @ApiModelProperty(value = "子权限列表")
    @TableField(exist = false)
    private List<SysPermission> children;
}
